    
    <style>
    
    .radio input[type="radio"], .radio-inline input[type="radio"], .checkbox input[type="checkbox"], .checkbox-inline input[type="checkbox"]{
		float:inherit;
		margin:auto;
		}
    
    </style>
    <div class="main-content">
        <!-- Content Header (Page header) -->
        <div class="breadcrumbs" id="breadcrumbs">
        	<script type="text/javascript">
				try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
			</script>
			<!-- .breadcrumb -->
        </div>
        <!-- Main content -->
         <div class="page-content">
            <div class="row">
            <div class="page-header">
				<h1>编辑角色</h1>
			</div>
			<div class="col-xs-12">
			<?php if (validation_errors()!=''){?>
	           <div id="info_msg" class="alert alert-danger"><?php echo validation_errors();?></div>
	        <?php }?>
	            <!-- general form elements disabled -->
	                <form id="usrform" role="form" action="<?php echo base_url().'admin/systems/edit_role/'.$role_info->id;?>" method="post">
	                	<input name="role_id" value="<?php if (isset($role_info->id)) echo $role_info->id; ?>" type="hidden"  />
	                	<div class="box-body" style="display: inline-block;width: 100%">
	                        <div class="form-group col-xs-6">
	                            <label>角色名称</label>
	                            <input name="role_name" type="text" value="<?php if (validation_errors()!='')echo set_value('role_name');elseif (isset($role_info->role_name)) echo $role_info->role_name; ?>" class="form-control" placeholder="输入 ..." check-type="required">
	                        </div>
	                        <div class="form-group col-xs-6">
	                            <label>角色部门</label>
	                            <?php if (isset($role_info->id)&&$role_info->id>1){?>
	                            <select name="department_id" class="form-control" check-type="required">
	                            	<option value="">请选择所属部门</option>
	                            	<?php if (isset($department)&&count($department)>0){
		                            	foreach ($department as $val){?>
		                            <option value="<?php echo $val->id?>" <?php if ($val->id==$role_info->department_id){?>selected<?php }?>><?php echo $val->text?></option>
		                            <?php }
		                            	}?>
	                            </select>
	                            <?php }else{?>
	                            <select name="department_id" class="form-control" check-type="required">
	                            	<option value="0">盛航健康</option>
	                            </select>
	                            <?php }?>
	                        </div>
	                        <div class="form-group col-xs-6">
	                            <label>角色键值</label>
	                            <input name="keyword" type="text" class="form-control" placeholder="输入 ..." check-type="required" value="<?php if (validation_errors()!='')echo set_value('keyword');elseif (isset($role_info->keyword))echo $role_info->keyword;?>">
	                        </div>
	                        <div class="form-group col-xs-6">
	                            <label>控制台地址</label>
	                            <input name="index_url" type="text" class="form-control" placeholder="输入 ..." check-type="required" value="<?php if (validation_errors()!='')echo set_value('index_url');elseif (isset($role_info->index_url))echo $role_info->index_url;?>">
	                        </div>
	                        <div class="form-group col-xs-6">
	                            <label>角色描述</label>
	                            <input name="description" type="text" value="<?php if (validation_errors()!='')echo set_value('description');elseif (isset($role_info->description)) echo $role_info->description; ?>" class="form-control" placeholder="输入 ..." check-type="required">
	                        </div>
	                        <div class="form-group col-xs-12">
	                        	<label>角色权限</label>
		                        <div class="col-xs-12" style="border: 1px solid #999;padding: 0px; margin-top:70px;">
			                        <?php if (isset($acl)&&count($acl)>0){
			                        	foreach ($acl as $val){
			                        	?>
			                        <div class="checkbox" style="border-bottom: 1px solid #999;">
										<label>
											<input class="ace" type="checkbox" name="acl_id[]" value="<?php echo $val->id?>" <?php if ($val->checked)echo "checked"?>/>
											<span class="lbl">&nbsp;<?php echo $val->acl_name?></span>
										</label>
										<?php if (count($val->child_acl)>0){
											foreach ($val->child_acl as $child){
											?>
										<div class="checkbox" style="padding-left: 25px;border-top: 1px solid #999;">
											<label>
											<input class="ace" type="checkbox" name="acl_id[]" value="<?php echo $child->id?>" <?php if ($child->checked)echo "checked"?>/>
											<span class="lbl">&nbsp;<?php echo $child->acl_name?></span>
											</label>
											<?php if (count($child->child_acl)>0){
											foreach ($child->child_acl as $child_child){
											?>
											<div class="checkbox" style="padding-left: 25px;">
												<label>
												<input class="ace" type="checkbox" name="acl_id[]" value="<?php echo $child_child->id?>" <?php if ($child_child->checked)echo "checked"?> />
												<span class="lbl">&nbsp;<?php echo $child_child->acl_name?></span>
												</label>
												<?php if (count($child_child->child_acl)>0){
												foreach ($child_child->child_acl as $child_child_child){
												?>
												<label style="margin-left: 15px;">
												<input class="ace" type="checkbox" name="acl_id[]" value="<?php echo $child_child_child->id?>" <?php if ($child_child_child->checked)echo "checked"?> />
												<span class="lbl"><?php echo $child_child_child->acl_name?></span>
												</label>
												<?php }
												}?> 
											</div>
											<?php }
											}?> 
										</div>
										<?php }
											}?>                                            
									</div>
									<?php }
		                        	}?>
		                        </div>
		                   	</div>
		                   	
	                	</div><!-- /.box-body -->
	                	<div class="clearfix form-actions">
						<div class="col-md-offset-3 col-md-9">
							<button id="btnSubmit" class="btn btn-info" type="submit">
								<i class="icon-ok bigger-110"></i>
								保存
							</button>

							&nbsp; &nbsp; &nbsp;
							<a class="btn" href="<?php echo base_url()."admin/systems/role"?>">
								<i class="icon-undo bigger-110"></i>
								返回
							</a>
						</div>
					</div>
	                </form>
	        </div>
		</div>
    </div>
</div>
<script type="text/javascript">
$("#usrform").validation();
//保存
$("#btnSubmit").on('click',function(event){
  // 2.最后要调用 valid()方法。
  if ($("#usrform").valid()==false){
    return false;
  }
});
$('div > label:first-child input:checkbox').on('click' , function(){
	var that = this;
	$(this).closest('div').find('div input:checkbox')
	.each(function(){
		this.checked = that.checked;;
	});
});
</script>